package com.demo.zookeeper;

import java.io.IOException;
import java.util.List;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class ZKGetChildren {
	
	private static ZooKeeper zk;

	public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
		zk = ZookeeperConnection.connect();
		String path = "/dataNode";
		Stat stat = zk.exists(path, true);
		if(stat != null) {
			List<String> childrens = zk.getChildren(path, false);
			for(int i = 0; i < childrens.size(); i++) {
				System.out.println(childrens.get(i));
			}
		}
		ZookeeperConnection.close();
	}

}
